/*
 *         Copyright (c) KUBOTA Corporation and HUDSON SOFT,
 *                  1994, 1995 All Rights Reserved
 *
 *  This software comprises unpublished confidential information of
 *  KUBOTA Corp. and HUDSON SOFT. It may not be used, copied or made 
 *  available to anyone, except in accordance with the license under
 *  which it is furnished.
 */
static char SccsId[] = "@(#)acrotzsc.c	1.5	9/19/95";
#include <farl.h>
#include <agl.h>

/*
 * 与えられたsin, cosでカメラＺ軸回転
 */
void
AGLRotateCameraZSC(fix1015 SinZZ, fix1015 CosZZ)
{
     fix187		sinz187, cosz187;

     if (SinZZ == 0 && CosZZ == 0x7fff) return;
     sinz187 = CONV1015TO187(SinZZ);
     cosz187 = CONV1015TO187(CosZZ);

     /*
      * カメラはマトリクスの逆回転で実現しているため、
      * sin(-angle), cos(-angle)を求める必要がある。
      * 	sin(-angle) = -sin(angle)
      * 	cos(-angle) = cos(angle)
      */
     /* camMatrix187を回転させる */
     if (__AGLCamera.camChanged == -2) {
	  FarlGetRotateZSC4x4M187(~sinz187+1, cosz187,
	  		(unsigned short*)__AGLCamera.camMatrix187);
     } else {
	  FarlSetSrcMatrix((unsigned short*)__AGLCamera.camMatrix187);
	 FarlRotateZSC4x4M187(~sinz187+1, cosz187);
	 FarlCopyDstToMem4x4((unsigned short*)__AGLCamera.camMatrix187);
     }

     /* camMatrix1015を回転させる */
     if (__AGLCamera.camChanged < 0) {
	  FarlGetRotateZSC3x3M1015(~SinZZ+1, CosZZ,
	  		(unsigned short*)__AGLCamera.camMatrix1015);
     } else {
	  FarlSetSrcMatrix3x3((unsigned short*)__AGLCamera.camMatrix1015);
	 FarlRotateZSC3x3M1015(~SinZZ+1, CosZZ);
	 FarlCopyDstToMem3x3((unsigned short*)__AGLCamera.camMatrix1015);
     }
     __AGLCamera.camChanged = 1;
}
